<{include file="header.htm"}>
<script src="<{$config.weburl}>/script/jquery-1.4.4.min.js" type="text/javascript"></script><header>
	<div class="nav-w">
    	<section class="nav-s"><a href="<{$config.weburl}>"><nav>首页</nav></a></section>
    	<section class="nav-c"><span>我的购物车</span></section>
   		<section class="nav-e"><a href="javascript:$('form').submit()"><nav>删除</nav></a></section>
    </div>
</header>
<link href="<{$config.weburl}>/templates/wap/css/cart.css" rel="stylesheet" type="text/css" />
<script language="javascript">
$(function(){
	/* 全选 */
	$('.checkall').click(function(){
		var _self = this;
		var obj=$(this).parent().parent();
		$(obj).find('input[type="checkbox"]').each(function(){
			if (!this.disabled)
			{
				$(this).attr('checked', _self.checked);
			}
		});
	});	 
});
</script>
<{if $smarty.get.type=="clear" || $cart.cart|@count<1}>
    <div class="cart-empty">
        购物车内暂时没有产品<br />您可以<a href="<{$config.weburl}>">去首页</a>挑选
    </div>
<{else}>  
<section class="cart">
<{if $smarty.get.type=="numf"}>
    <div align="center"><font color="#FF0000">库存数量不够(已经为定订购产品的最大值)</font></div>
<{elseif $smarty.get.type=="pronull"}>
    <div align="center"> <font color="#FF0000">产品不存在或订购销完或已经删除</font></div>
<{elseif $smarty.get.type=="del"}>
    <div align="center"><font color="#FF0000">购物车不存在该产品已经删除</font></div>
<{/if}>
<form id="form" name="form" method="post">
<input type="hidden" name="act" value="del">
<{foreach item=list from=$cart.cart}>  
<div class="item">
 	<!--<div class="top"></div>	-->
    <div>
	<{foreach item=pro key=n from=$list.prolist}>
        <dl class="clearfix">
        <dt>
       	 	<input type="checkbox" value="<{$pro.id}>" class="checkitem" name="checkbox[]">
       		<img height="80" alt="<{$pro.name}>" src="<{$pro.pic}>_220X220.jpg">
        </dt>
        <dd>
            <p class="p-name"><{$pro.pname}></p>
			<p class="p-price">
            	<strong><{$config.money}><{$pro.price|number_format:2}></strong>
                <input data-param='{"id":"<{$pro.id}>"}' name="nums" id="nums" oninput="javascript:inputBuynum(this);" class="numIpt" type="number" value="<{$pro.num}>" min="1" max="<{$pro.stock}>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'');">
            </p>
            <{if $pro.product_give}>
            <{foreach item=list from=$pro.product_give}>
            <p class="p-detail">[赠品] <{$list.pname}></p>
            <{/foreach}>
            <{/if}>
            <{if $pro.service}>
            <{foreach item=list from=$pro.service}>
            <p class="p-detail">[服务] <{$list.name}>&nbsp;&nbsp;<b class="red"><{$config.money}><{$list.price}></b></p>
            <{/foreach}>
            <{/if}>
        </dd>
        </dl>
    <{/foreach}>
    </div>
 	<!--<div class="bottom"></div>	-->   
</div>	
<{/foreach}>
</form>
<script>
function inputBuynum(ele){
	var _this=$(ele);
	var inputindex = $(".numIpt").index(_this);
	var buyNum = $(".numIpt").eq(inputindex).val();
	var maxNum = $(".numIpt").eq(inputindex).attr("max");
	var data_str = $(".numIpt").eq(inputindex).attr("data-param");
	eval("data_str = "+data_str);
	if(buyNum!=null&&buyNum!=""){
		if(Number(buyNum)<0||Number(buyNum)>Number(maxNum)){
			alert("输入的数量有误,应为[1-"+maxNum+"]");
			$(".numIpt").eq(inputindex).val('1');
		}
		else
		{
			window.location="<{$config.weburl}>/?m=product&s=shop_cart&id="+data_str.id+"&cgnum="+buyNum;	
		}
	}
} 
</script>
</section>
<footer>
总计（不含运费）:&nbsp;&nbsp;<span class="p-price"><strong><{$config.money}><{$cart.sumprice|number_format:2}></strong></span>
<a class="checkout" href="<{$config.weburl}>/?m=product&s=shop_order">去结算</a>
</footer>
<{/if}>
</body>
</html>
